{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "class Solution:\n",
    "    def removeDuplicates(self, nums: List[int]) -> int:\n",
    "        i = 0\n",
    "        if(len(nums) < 3):\n",
    "            return len(nums)\n",
    "        i = 2\n",
    "        for e in nums[2::1]:\n",
    "            if e != nums[i - 2]:\n",
    "                nums[i] = e\n",
    "                i += 1\n",
    "        return i"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "7\n",
      "[0, 0, 1, 1, 2, 3, 3, 3, 3]\n"
     ]
    }
   ],
   "source": [
    "nums = [0,0,1,1,1,1,2,3,3]\n",
    "#nums = [1,1,1,2,2,3]\n",
    "#nums = [1,2,2,2]\n",
    "a = Solution()\n",
    "print(a.removeDuplicates(nums))\n",
    "print(nums)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
